This document is dedicated to conducting the confirmatory performance analyses that were proposed for Experiment 2.
Design. The design and analysis is a 2 (difficulty: harder than reference vs. easier than reference) X 2 (difference: moderate vs. extreme) X 2 (transition: repeat vs. switch) within-subjects ANOVA on RTs and error rates.
In retrospect, I’m realizing this design doesn’t make sense because, unlike in Experiment 1, decks aren’t associated with a single level of intensity, but rather the risky deck can always have two outcomes. I think trying to coerce this analysis into the difference X difficulty design would introduce a lot of unnecessary complexity.
I’m taking a step back and thinking about what the actual insights are that I want to get out of this performance data. Are RTs and error rates slower and higher for runs of trials with more switches rather than fewer? Is the switch cost greater when switching occurs less frequently? Thinking about it this way compels me to analyze performance based on numbers of switches in a run, regardless of what deck the run comes from. It might also be interesting to explore how the actual decks influence performance, but that would be more of an exploratory performance analysis.
The analysis I’ll conduct to investigate the above is a regression where number of switches in a run and transition type predict RTs (and errors). The prediction is that RTs will be positively associated with number of switches in a run, RTs will be positively predicted by transition such that switch trials have longer RTs (i.e., the switch cost), and there will be an interaction such that the impact of transition on RT will be greater in runs where switching occurs less frequently.
Below is the cleaned data:
d <- read.csv('../../../data/dstClean.csv')
d <- d %>%
filter(transition != 'startBlock')
N <- d %>%
group_by(subject) %>%
summarize(n()) %>%
nrow(.)
d
The sample size is 70.
subjectCellMeans <- d %>%
filter(transition != 'startBlock') %>%
group_by(subject, outcomeSwitch, transition) %>%
summarize(rtime = mean(cuedRt))
subjectCellMeans %>%
group_by(outcomeSwitch, transition) %>%
summarize(rt = mean(rtime), se = sd(rtime) / sqrt(N)) %>%
ggplot(aes(x = factor(outcomeSwitch), y = rt, group = transition)) +
geom_point(size = 2) +
geom_line(aes(linetype = transition)) +
geom_errorbar(aes(ymin = rt - se, ymax = rt + se), width = 0.5) +
labs(
x = 'Number of Switches in a Run',
y = 'Response Time (ms)'
) +
scale_linetype_discrete(name = 'Transition Type', labels = c('Repeat', 'Switch')) +
theme_bw() +
theme(legend.position = c(.9,.5),
panel.grid = element_blank())
d$outcomeSwitchC <- d$outcomeSwitch - 8
d$transitionE <- ifelse(d$transition == 'repeat', -0.5, 0.5)
m1 <- lm(cuedRt ~ transitionE * outcomeSwitchC, data = d)
plot(m1)
summary(m1)
##
## Call:
## lm(formula = cuedRt ~ transitionE * outcomeSwitchC, data = d)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1138.5 -273.9 -103.2 147.5 3748.8
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1011.236 2.449 412.941 < 2e-16 ***
## transitionE 268.442 4.898 54.810 < 2e-16 ***
## outcomeSwitchC 3.525 0.799 4.411 1.03e-05 ***
## transitionE:outcomeSwitchC -5.059 1.598 -3.166 0.00155 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 437.1 on 37409 degrees of freedom
## Multiple R-squared: 0.09189, Adjusted R-squared: 0.09182
## F-statistic: 1262 on 3 and 37409 DF, p-value: < 2.2e-16
newdata <- data.frame(outcomeSwitch = rep(unique(d$outcomeSwitch), 2), transition = c(rep(-0.5, length(unique(d$outcomeSwitch))), rep(0.5, length(unique(d$outcomeSwitch)))))
newdata$proba <- m1$coefficients[1] + newdata$outcomeSwitch * m1$coefficients[3] + newdata$transition * m1$coefficients[2] + newdata$transition * newdata$outcomeSwitch * m1$coefficients[4]
newdata$transitionE <- newdata$transition
newdata$outcomeSwitchC <- newdata$outcomeSwitch - 8
newdata$transition <- ifelse(newdata$transition == -0.5, 'repeat', 'switch')
newdata <- cbind(newdata, predict(m1, newdata, interval = 'predict'))
ggplot(newdata, aes(x = factor(outcomeSwitch), y = fit, group = transition)) +
geom_jitter(data = subjectCellMeans, aes(x = factor(outcomeSwitch), y = rtime, color = factor(transition)), alpha = .2, width = .2, height = 0, show.legend = FALSE) +
geom_line(size = 2, aes(color = factor(transition))) +
#geom_ribbon(aes(ymin = lwr, ymax = upr, fill = factor(transition)), alpha = .1, show.legend = FALSE) +
scale_color_manual(name = 'Transition Type', values = c(`repeat` = 'blue', `switch` = 'red'), labels = c('Repeat', 'Switch')) +
#scale_fill_manual(values = c(`repeat` = 'blue', `switch` = 'red')) +
labs(
x = 'Number of Switches in a Run',
y = 'Response Time (ms)',
caption = 'Lines reflect predictions from regression. Points reflect subject-wise cell means.'
) +
theme_bw() +
theme(legend.position = c(.8,.85),
panel.grid = element_blank())
Centering at high number of switches per run (12)
d$outcomeSwitchC <- d$outcomeSwitch - 12
d$transitionE <- ifelse(d$transition == 'repeat', -0.5, 0.5)
m1 <- lm(cuedRt ~ transitionE * outcomeSwitchC, data = d)
summary(m1)
##
## Call:
## lm(formula = cuedRt ~ transitionE * outcomeSwitchC, data = d)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1138.5 -273.9 -103.2 147.5 3748.8
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1025.335 4.076 251.557 < 2e-16 ***
## transitionE 248.206 8.152 30.448 < 2e-16 ***
## outcomeSwitchC 3.525 0.799 4.411 1.03e-05 ***
## transitionE:outcomeSwitchC -5.059 1.598 -3.166 0.00155 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 437.1 on 37409 degrees of freedom
## Multiple R-squared: 0.09189, Adjusted R-squared: 0.09182
## F-statistic: 1262 on 3 and 37409 DF, p-value: < 2.2e-16
And centering at low number of switches per run (4)
d$outcomeSwitchC <- d$outcomeSwitch - 4
d$transitionE <- ifelse(d$transition == 'repeat', -0.5, 0.5)
m1 <- lm(cuedRt ~ transitionE * outcomeSwitchC, data = d)
summary(m1)
##
## Call:
## lm(formula = cuedRt ~ transitionE * outcomeSwitchC, data = d)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1138.5 -273.9 -103.2 147.5 3748.8
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 997.138 3.976 250.800 < 2e-16 ***
## transitionE 288.679 7.952 36.304 < 2e-16 ***
## outcomeSwitchC 3.525 0.799 4.411 1.03e-05 ***
## transitionE:outcomeSwitchC -5.059 1.598 -3.166 0.00155 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 437.1 on 37409 degrees of freedom
## Multiple R-squared: 0.09189, Adjusted R-squared: 0.09182
## F-statistic: 1262 on 3 and 37409 DF, p-value: < 2.2e-16
Response times are associated with an increase in 289 ms when there are few switches per run, and they are only associated with an increase of 248 ms when there are many switches per run. This analysis needs to be interpreted with caution, however, because the independent variables are obviously highly related, thus violating an assumption of the regression.
Looking at the relationship between switches in a run and mean RT (dropping transition)
m2 <- lm(cuedRt ~ outcomeSwitch, data = d)
slope <- round(m2$coefficients[2], 2)
sMeans <- d %>%
group_by(subject, outcomeSwitch) %>%
summarize(rtime = mean(cuedRt))
sMeans %>%
group_by(outcomeSwitch) %>%
summarize(rt = mean(rtime), se = sd(rtime) / sqrt(N)) %>%
ggplot(aes(x = factor(outcomeSwitch), y = rt, group = 1)) +
geom_line() +
geom_point(size = 2.5) +
geom_jitter(data = sMeans, aes(x = factor(outcomeSwitch), y = rtime), alpha = .2, width = .1, height = 0) +
geom_errorbar(aes(ymin = rt - se, ymax = rt + se), width = 0.5) +
annotate('text', x = 4, y = 1500, label = paste('b = ', slope, '***', sep = '')) +
labs(
x = 'Number of Switches in a Run',
y = 'Response Time (ms)',
caption = '*** p < .001'
) +
theme_bw() +
theme(panel.grid = element_blank())
A work by Dave Braun
dab414@lehigh.edu